﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreEx.Common.Proxy;
using LinFu.IoC.Configuration;
using Mono.Cecil;
using System.Reflection;

namespace CoreEx.Common.Tests
{
    [Implements(typeof(IMethodModifier))]
    public class SampleMethodModifier : IMethodModifier
    {
        public void BeforeConstruction(TypeDefinition targetType, MethodInfo method)
        {
            
        }

        public void AfterConstruction(TypeDefinition targetType, MethodInfo method,MethodDefinition returnValue)
        {
            MethodReference methodReference 
                =  returnValue.DeclaringType.Module.Import(typeof(SampleAttribute).GetConstructor(new Type[] { }));
            returnValue.CustomAttributes.Add(new CustomAttribute(methodReference));
            
        }
    }
}
